Ignore dot dirs in directory sources
authorAlex Crichton <alex@alexcrichton.com>
Fri, 16 Dec 2016 20:54:47 +0000 (12:54 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 20 Dec 2016 01:19:41 +0000 (17:19 -0800)
Looks like they'll conflict with a VCS, so let's just skip them like we do in
directory traversal elsewhere.

Closes #3414

src/cargo/sources/directory.rs

index 96d06a8be462aaacf1d85ac8453004491f1d7d9c..661cff6f993876d00ad281e1e1a7f1174338ae0a 100644 (file)
@@ -71,6 +71,16 @@ impl<'cfg> Source for DirectorySource<'cfg> {
         for entry in entries {
             let entry = entry?;
             let path = entry.path();
+
+            // Ignore hidden/dot directories as they typically don't contain
+            // crates and otherwise may conflict with a VCS
+            // (rust-lang/cargo#3414).
+            if let Some(s) = path.file_name().and_then(|s| s.to_str()) {
+                if s.starts_with(".") {
+                    continue
+                }
+            }
+
             let mut src = PathSource::new(&path, &self.source_id, self.config);
             src.update()?;
             let pkg = src.root_package()?;